package com.example.wxy2.dao;

import com.example.wxy2.entity.data;
import com.example.wxy2.entity.login;
import com.example.wxy2.entity.rules;
import com.example.wxy2.entity.stateDto;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Mapper
public interface loginMapper2 {

    @Select("select * from login where username = #{username} AND password = #{password}")
    login login(@Param("username") String username, @Param("password") String password);

    @Select("select * from data where operator = #{username}")
    List<data> findAll(@Param("username") String username);


//    void updatestate(@Param("list") stateDto stateDto);

    @Update("update rules set level = #{level} where typeid = #{typeid}")
    void updateRules(@RequestBody rules rules);

    @Select("select * from rules")
    List<rules> getRules();

    @Insert("insert into login(username, password, name, sex) values(#{username},#{password},#{name},#{sex}) ")
    void adduser(login login);

    @Select("select * from login where  username=#{username} ")
    login checkadmin(@Param("username") String admin);


    @Delete("delete from login where username = #{username}")
    void deleteUser(@RequestBody login login);

    @Select("select * from login")
    List<login> findUser();
}
